package enumdemo;

import enumdemo.TestEnum;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2025-03-29
 * Time: 16:43
 */
public class Test {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class<?> c1 = Class.forName("enumdemo.TestEnum");

        Constructor[] constructors = c1.getConstructors();
        for (int i = 0; i < constructors.length; i++) {
            System.out.println(constructors[i]);
        }
        System.out.println("===========");
        Constructor<?> constructor = c1.getConstructor(int.class,String.class);

        constructor.setAccessible(true);
        TestEnum testEnum = (TestEnum)constructor.newInstance(2,"黄色");
        System.out.println(testEnum);
    }
}
